#ifndef DWARF__DIE_H
#define DWARF__DIE_H

#include "RaiiDie.h"
#include "Value.h"

namespace dwarf {

class Die {
public:
	static RaiiDie getChild(Dwarf_Debug _debug, Dwarf_Die _die);
	static RaiiDie getSibling(Dwarf_Debug _debug, Dwarf_Die _die);
public:
	static int getTag(Dwarf_Die _die, Dwarf_Half &_tag);
public:
	static int getAttribute(Dwarf_Die _die, Dwarf_Half _type, RaiiPointer<Dwarf_Attribute> &_attribute);
public:
	static int getAbstractOrigin(Dwarf_Attribute _attribute, Dwarf_Off &_abstractOrigin);
	static int getAbstractOrigin(Dwarf_Debug _debug, Dwarf_Die _die, Dwarf_Off &_abstractOrigin);
	static int getBitOffset(Dwarf_Debug _debug, Dwarf_Die _die, Dwarf_Unsigned &_bitOffset);
	static int getBitSize(Dwarf_Attribute _attribute, Dwarf_Unsigned &_bitSize);
	static int getConstValue(Dwarf_Debug _debug, Dwarf_Attribute _attribute, Value &_constValue);
	static int getConstValue(Dwarf_Debug _debug, Dwarf_Die _die, Value &_constValue);
	static int getEncoding(Dwarf_Debug _debug, Dwarf_Die _die, Dwarf_Unsigned &_encoding);
	static int getExternal(Dwarf_Attribute _attribute, bool &_external);
	static int getHighPc(Dwarf_Debug _debug, Dwarf_Die _die, const void *_lowPc, void *&_highPc);
	static int getLocationDescription(Dwarf_Debug _debug, Dwarf_Die _die, Dwarf_Attribute _attribute, RaiiPointer<Dwarf_Locdesc *> &_locationDescription);
	static int getLocationDescription(Dwarf_Debug _debug, Dwarf_Die _die, RaiiPointer<Dwarf_Locdesc *> &_locationDescription);
	static int getName(Dwarf_Die _die, RaiiPointer<char *> &_name);
	static int getType(Dwarf_Debug _debug, Dwarf_Die _die, RaiiPointer<Dwarf_Die> &_type);
	static int getUpperBound(Dwarf_Debug _debug, Dwarf_Die _die, Dwarf_Unsigned &_upperBound);
public:
	static bool getArgumentAddress(Dwarf_Debug _debug, Dwarf_Die _argument, const void *_frame, void *&_address);
	static int getLocalAddress(Dwarf_Debug _debug, Dwarf_Die _local, const void *_frame, void *&_address);
	static int getMemberAddress(Dwarf_Debug _debug, Dwarf_Die _member, const void *_object, void *&_address);
private:
	Die();
	Die(const Die &_die);
	~Die();
};

}

#endif // DWARF__DIE_H
